﻿using System.Windows.Controls;
using Autofac;
using CommunityToolkit.Mvvm.ComponentModel;
using MG.SmartHMI.View;
using MG.SmartHMI.View.Pages.Setting;

namespace MG.SmartHMI.ViewModel
{
    public partial class SettingViewModel : ObservableRecipient
    {
        [ObservableProperty]
        private int menuSelectedIndex = 1;

        [ObservableProperty]
        private UserControl childView;

        public SettingViewModel()
        {
            MenuSelectedIndex = 0;
            SwitchChildMenu(MenuSelectedIndex);
        }

        partial void OnMenuSelectedIndexChanged(int value) => SwitchChildMenu(value);

        private void SwitchChildMenu(int index)
        {
            switch (index)
            {
                case 0:
                    ChildView = App.Service.Resolve<RegisterView>();
                    break;

                case 1:
                    ChildView = App.Service.Resolve<AxisView>();
                    break;

                case 2:
                    ChildView = App.Service.Resolve<MessageStateView>();
                    break;

                case 3:
                    ChildView = App.Service.Resolve<ConfigView>();
                    break;

                default:
                    // ChildView = App.Service.Resolve<IOInView>();
                    break;
            }
        }
    }
}